package au.com.handsunited.web.taglib.relationship;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import au.com.handsunited.model.BaseEntity;
import au.com.handsunited.model.relationship.Relationship;


/**
 * @author arunda
 *
 */
public class RelationshipTag extends BodyTagSupport {

	private static Logger logger = LoggerFactory.getLogger(RelationshipTag.class);


	private BaseEntity entity;

	private BaseEntity member;

	private Relationship relationship;


	/**
	 *
	 */
	public RelationshipTag() {

	}

	/**
	 * @see javax.servlet.jsp.tagext.BodyTagSupport#doStartTag()
	 */
	@Override
	public int doStartTag() throws JspException {
		return EVAL_BODY_INCLUDE;
	}

	/**
	 * @return the entity
	 */
	public BaseEntity getEntity() {
		return entity;
	}

	/**
	 * @param entity the entity to set
	 */
	public void setEntity(BaseEntity entity) {
		this.entity = entity;
	}

	/**
	 * @return the member
	 */
	public BaseEntity getMember() {
		return member;
	}

	/**
	 * @param member the member to set
	 */
	public void setMember(BaseEntity member) {
		this.member = member;
	}

	/**
	 * @return the relationship
	 */
	public Relationship getRelationship() {
		if (relationship == null) {
			relationship = entity.findRelationshipWith(member);
		}
		return relationship;
	}

}
